Making "Enter" Work for Multiple Fields

Forms with a single text field will autosubmit when you press enter. Here's how you can make this convenient feature work for multiple fields. (Use tabs to move between fields.)
F1:

F2:

F3:

Discussion

This is not, in fact, a single form. Three forms work together to mimic a form which submits on "Enter". These forms use the merge function to combine distributed data into a single submission.
// Pluses must be placed only between valid entries
function merge(s1, s2)
{
    if ((s1.length > 0) && (s2.length > 0)) return(s1+'+'+s2)
    return(s1+s2)
}

// Handle "submission"
function doEnter()
{
    var t1 = code('f1', document.forms[0].F1.value)
    var t2 = code('f2', document.forms[1].F1.value)
    var t3 = code('f3', document.forms[2].F1.value)
    var tmp = merge(t1, t2)
    tmp = merge(tmp, t3)

    //replace this with a real call to a new location.HREF
    alert("HTTP://www.foo.com?"+tmp)
}
In early versions of Navigator 2.0 and 3.0, the fields sometimes "chase" each other creating a nifty strobe effect. Simply reload and this problem will stop.
Copyright ©2000 by Charles River Media, All Rights Reserved